
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <include file="./Public/Admin/header.html" />
    <style>
        .row-fluid [class*="span"]{margin-left:0px;margin-bottom:10px;}
    </style>
</head>
<body>
<body>
<div id="main">
    <div class="container-fluid">
        <div class="row-fluid">
            <div class="span12">
                <div class="box">
                    <div class="box-title">
                        <div class="span4">
                            <h3><i class="icon-table"></i>分组管理</h3>
                        </div>

                    </div>
                    <div class="box-content">
                        <div class="row-fluid">
                            <div class="span8 control-group">
                                <div class="span2">
                                    <a class="btn" href="{:U('Admin/Wechat/group_edit')}?action=add"><i class="icon-plus"></i>添加分组</a>
                                </div>

                                <div class="span10">

                                    <div class="btn-group">
                                        <a class="btn" attr="BatchDelInfo" title="批量删除"><i class="icon-trash"></i>批量删除</a>
                                    </div>
                                </div>

                            </div>


                        </div>
                        <div class="row-fluid">
                            <div class="span12">
                                <form action="{:U('Admin/Wechat/groups')}" method="get" class="form-horizontal">
                                    <div class="span12">
                                        <div class="span6">
                                            分组名称：<input type="text" id="keyword" name="keyword" value="{$keyword}" placeholder="请输入分组名称" />
                                            <button class="btn">查询</button>
                                        </div>
                                    </div>

                                </form>
                            </div>

                        </div>

                        <div class="row-fluid dataTables_wrapper" >
                            <table id="listTable" class="table table-bordered table-hover  dataTable">
                                <thead>
                                <tr>
                                    <th class='with-checkbox'>
                                        <input type="checkbox" class="check_all" /></th>
                                    <th>分组名称</th>
                                    <th>成员数量</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                <if condition="$total gt 0">
                                <foreach name="groups" item="item">
                                <tr>
                                    <td class="with-checkbox">
                                        <input type="checkbox" name="check" value="{$item.id}">
                                    </td>
                                    <td>{$item.groupname}</td>
                                    <td>{$item.wx_user_group|count}</td>
                                    <td class='hidden-480'>
                                        <a href="{:U('Admin/Wechat/userlist')}?group_id={$item.id}" class="btn" rel="tooltip" title="查看成员"><i class="icon-search"></i>查看成员</a>
                                        <a href="{:U('Admin/Wechat/group_edit')}?action=edit&id={$item.id}" class="btn" rel="tooltip" title="修改名称"><i class="icon-edit"></i>修改名称</a>
                                        <a href="javascript:void(0);" class="btn" rel="tooltip" title="删除" attr="del*text*{$item.id}"><i class="icon-trash"></i>删除</a>
                                    </td>
                                </tr>
                                </foreach>
                                </if>
                                </tbody>
                            </table>
                            <div class="row-fluid">
                                <div class="span4">
                                    <div class="dataTables_info">
                                        <if condition="$total gt 0">
                                            共{$total}条记录，当前第{$nowPage}/{$totalPages}页
                                        </if>
                                    </div>
                                </div>
                                <div class="span8">
                                    <div class="dataTables_paginate paging_full_numbers">
                                        <span>
                                            {$page}
                                        </span>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

        </div>
    </div>
</div>
<script type="text/javascript">
    $(function(){
        //删除内容
        $("a[attr^='del*text*']").click(function(){
            var tmp = $(this).attr('attr').split('*');
            var ids = new Array();
            ids[0]=tmp[2];
            delText(ids);
        });
        $("[attr='BatchDelInfo']").click(function(){
            var check = $("input:checked").not($(".check_all")[0]);
            if(check.length<1){
                alert('请选择删除项');
                return false;
            }
            var ids = new Array();
            check.each(function(i){
                ids[i] = $(this).val();
            });
            delText(ids);
        });
    });
    //删除内容
    function delText(ids){
        G.ui.tips.confirm_flag('您确定要删除吗?',function(){
            $.post("{:U('Admin/Wechat/del_group')}", {ids:ids},function(data){
                if (data.errno ==0)
                {
                    location.reload();
                } else {
                    G.ui.tips.err(data.error);
                }
            },'json');
        });
    }
</script>
</body>
</html>
